From 2cc42c02a4b1b3efeeb6dfb98e13ba68398af2fa Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 29 Jul 2003 19:29:14 +0000 Subject: [PATCH] Make GPX input modules optional. --- Makefile | 11 +++++++++-- geo.c | 52 ++++++++++++++++++++++++++++++++++------------------ gpx.c | 19 ++++++++++++++++--- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index b20769b39..519235264 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ + +# If you do not have libexpat and you have no use for reading any input +# type that is XML-ish (i.e. gpx or geocaching.com's/loc) you can uncomment +# INHIBIT_EXPAT and coment out LIBEXPAT on just to get a build working quickly. +# INHIBIT_EXPAT=-DNO_EXPAT +LIBEXPAT=-lexpat + # add -DDEBUG_MEM to turn on memory allocation logging -CFLAGS=$(EXTRA_CFLAGS) -g -Icoldsync +CFLAGS=$(EXTRA_CFLAGS) -g -Icoldsync $(INHIBIT_EXPAT) INSTALL_TARGETDIR=/usr/local/ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o \ @@ -29,7 +36,7 @@ OBJS = main.o $(LIBOBJS) all: gpsbabel gpsbabel: $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o gpsbabel -lexpat -lm + $(CC) $(CFLAGS) $(OBJS) -o gpsbabel $(LIBEXPAT) -lm main.o: $(CC) -c $(CFLAGS) -DVERSION=\"$(VERSIOND)\" $< diff --git a/geo.c b/geo.c index 959669f55..0957387a6 100644 --- a/geo.c +++ b/geo.c @@ -17,7 +17,10 @@ */ #include "defs.h" +#if !NO_EXPAT #include +static XML_Parser psr; +#endif static int in_wpt; static int in_name; @@ -27,7 +30,6 @@ static int in_cdata; static char *cdatastr; static char *typestr; -static XML_Parser psr; static waypoint *wpt_tmp; FILE *fd; @@ -36,6 +38,18 @@ FILE *ofd; #define MYNAME "geo" #define MY_CBUF 4096 +#if NO_EXPAT +void +geo_rd_init(const char *fname, const char *args) +{ + fatal(MYNAME ": This build excluded GPX support becuase expat was not installed.\n"); +} + +void +geo_read(void) +{ +} +#else static void tag_coord(const char **attrv) { @@ -189,6 +203,25 @@ geo_rd_init(const char *fname, const char *args) XML_SetCharacterDataHandler(psr, geo_cdata); } +void +geo_read(void) +{ + int len; + char buf[MY_CBUF]; + + while ((len = fread(buf, 1, sizeof(buf), fd))) { + if (!XML_Parse(psr, buf, len, feof(fd))) { + fatal(MYNAME ":Parse error at %d: %s\n", + XML_GetCurrentLineNumber(psr), + XML_ErrorString(XML_GetErrorCode(psr))); + } + } + + XML_ParserFree(psr); +} + +#endif + void geo_rd_deinit(void) { @@ -216,23 +249,6 @@ geo_wr_deinit(void) fclose(ofd); } -void -geo_read(void) -{ - int len; - char buf[MY_CBUF]; - - while ((len = fread(buf, 1, sizeof(buf), fd))) { - if (!XML_Parse(psr, buf, len, feof(fd))) { - fatal(MYNAME ":Parse error at %d: %s\n", - XML_GetCurrentLineNumber(psr), - XML_ErrorString(XML_GetErrorCode(psr))); - } - } - - XML_ParserFree(psr); -} - static void geo_waypt_pr(const waypoint *waypointp) { diff --git a/gpx.c b/gpx.c index 9de09829b..5ed82708e 100644 --- a/gpx.c +++ b/gpx.c @@ -20,7 +20,10 @@ */ #include "defs.h" -#include +#ifndef NO_EXPAT + #include + static XML_Parser psr; +#endif static int in_wpt; static int in_rte; @@ -53,8 +56,6 @@ static char *cdatastr; static int opt_logpoint = 0; static int logpoint_ct = 0; -static XML_Parser psr; - static const char *gpx_version; static const char *gpx_creator; @@ -671,6 +672,15 @@ gpx_end(void *data, const char *el) } } +#if NO_EXPAT +void +gpx_rd_init(const char *fname, const char *args) +{ + fatal(MYNAME ": This build excluded GPX support becuase expat was not installed.\n"); +} + +#else /* NO_EXPAT */ + static void gpx_cdata(void *dta, const XML_Char *s, int len) { @@ -761,6 +771,7 @@ gpx_rd_init(const char *fname, const char *args) XML_SetElementHandler(psr, gpx_start, gpx_end); XML_SetCharacterDataHandler(psr, gpx_cdata); } +#endif static void gpx_rd_deinit(void) @@ -795,6 +806,7 @@ gpx_wr_deinit(void) void gpx_read(void) { +#ifndef NO_EXPAT int len; int done = 0; char buf[MY_CBUF]; @@ -822,6 +834,7 @@ gpx_read(void) XML_ErrorString(XML_GetErrorCode(psr))); } } +#endif /* NO_EXPAT */ } /* -- 2.30.2